#include<bits/stdc++.h>
using namespace std;
const int p=998244353;
int main(){
  freopen("song.in","r",stdin);
  freopen("song.out","w",stdout);
  ios::sync_with_stdio(false);
  string s; bool D=true; int r=0; cin>>s;
  for(int i=1;i<s.length();i++)
    D&=s[i-1]!=s[i];
  if(D){
    if(s.length()&1)cout<<(s.length()+1>>1)<<endl;
    else cout<<(s.length()>>1)+(s[0]=='B')<<endl;
  }
  else if(s.length()<=20){
    set<string> T; T.emplace(s);
    queue<string> q; q.emplace(s);
    while(!q.empty()){
      auto u=q.front(); r++,q.pop();
      for(int i=1;i<u.length();i++)
        if(u[i-1]=='B'||u[i]=='A'){
          string v;
          for(int j=0;j<u.length();j++)
            if(j!=i-1&&j!=i)v+=u[j];
          if(T.find(v)==T.end())
            T.emplace(v),q.emplace(v);
        }
    }
    cout<<r<<endl;
  }
  return 0;
}